package com.minimalist.common.feign.client.lindi;

import com.minimalist.common.config.mybatis.bo.PageResp;
import com.minimalist.common.entity.lindi.vo.news.LindiNewsQueryVO;
import com.minimalist.common.entity.lindi.vo.news.LindiNewsVO;
import com.minimalist.common.feign.config.FeignConfig;
import com.minimalist.common.feign.fallback.lindi.LindiNewsFeignClientFallbackFactory;
import com.minimalist.common.response.R;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.constraints.NotNull;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 林地新闻 Feign 客户端
 *
 * @author minimalist
 */
@FeignClient(name = "minimalist-lindi"
        , contextId = "lindiNewsFeignClient"
        , path = "/minimalist/lindi/news"
        , configuration = FeignConfig.class
        , fallbackFactory = LindiNewsFeignClientFallbackFactory.class)
public interface LindiNewsFeignClient{

    /**
     * 添加新闻
     *
     * @param newsVO 新闻信息
     * @return 响应结果
     */
    @PostMapping("/addNews")
    @Operation(summary = "添加新闻")
    R<?> addNews(@RequestBody @Validated(Add.class) LindiNewsVO newsVO);

    /**
     * 修改新闻
     *
     * @param newsVO 新闻信息
     * @return 响应结果
     */
    @PutMapping("/updateNewsByNewsId")
    @Operation(summary = "修改新闻")
    R<?> updateNewsByNewsId(@RequestBody @Validated(Update.class) LindiNewsVO newsVO);

    /**
     * 删除新闻
     *
     * @param newsId 新闻ID
     * @return 响应结果
     */
    @DeleteMapping("/deleteNewsByNewsId")
    @Operation(summary = "删除新闻 -> 根据新闻ID删除")
    R<?> deleteNewsByNewsId(
            @RequestParam("newsId")
            @NotNull(message = "新闻ID不能为空")
            @Parameter(name = "newsId", required = true, description = "新闻ID")
            Long newsId);

    /**
     * 获取新闻详情
     *
     * @param newsId 新闻ID
     * @return 新闻详情
     */
    @GetMapping("/getNewsByNewsId/{newsId}")
    @Operation(summary = "根据新闻ID查询新闻")
    R<LindiNewsVO> getNewsByNewsId(
            @PathVariable("newsId")
            @NotNull(message = "新闻ID不能为空")
            @Parameter(name = "newsId", description = "新闻ID", required = true)
            Long newsId);

    /**
     * 分页查询新闻列表
     *
     * @param queryVO 查询条件
     * @return 新闻列表
     */
    @GetMapping("/getPageNewsList")
    @Operation(summary = "查询新闻列表(分页)")
    R<PageResp<LindiNewsVO>> getPageNewsList(@RequestBody LindiNewsQueryVO queryVO);
}